/**
 * Copyright 2006 Brad Reynolds
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.leeloo.databinding.internal.ui;

import junit.framework.TestCase;

import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.debug.core.IJavaBreakpoint;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;

public class BreakpointsBuilderTest extends TestCase {
    private static final String BINDING_CLASS_NAME = "org.eclipse.jface.databinding.Binding";
    
    public void testCreateLineBreakpoint() throws Exception {
        BreakpointsBuilder builder = new BreakpointsBuilder();
        
        IResource resource = Resources.getResourceForClassName(BINDING_CLASS_NAME);
        assertNotNull("Binding resource could not be loaded.  ensure that test is running in a workspace with Binding imported.", resource);
        
        String snippet = "snippet";
        int lineNumber = 1;
        
        builder.addLineBreakpoint(resource, BINDING_CLASS_NAME, lineNumber, snippet);
        IJavaBreakpoint[] breakpoints = builder.build();
        
        assertNotNull(breakpoints);
        assertEquals(1, breakpoints.length);
        IJavaLineBreakpoint breakpoint = (IJavaLineBreakpoint) breakpoints[0];
        assertEquals(BINDING_CLASS_NAME, breakpoint.getTypeName());
        assertEquals(snippet, breakpoint.getCondition());
        assertTrue(breakpoint.isConditionEnabled());
        assertEquals(lineNumber, breakpoint.getLineNumber());
    }
}